const path = require('path');
const jwtUtils = require('../../utils/jwtUtils.js');

const imgStatic = (req, res) => {
    try {
        const token = req.headers['authorization']?.split(' ')[1];
        if (!token) {
            return res.status(401).send("Unauthorized,未提供token");
        }
        jwtUtils.verifyToken(token);
    } catch (error) {
        console.error("Token 验证失败:", error.message);
        return res.status(401).send(error.message);
    }
    res.status(200);
    res.setHeader('Content-Type', 'image/jpeg');
    res.sendFile(path.join(__dirname, '../../../public/img/sunrun.jpg'));
}
module.exports = imgStatic;